// 用户角色枚举
export enum UserRole {
  ADMIN = 'admin',
  USER = 'user'
}

// 权限枚举
export enum Permission {
  VIEW_HOME = 'view_home',
  VIEW_CREATE = 'view_create',
  VIEW_AI = 'view_ai',
  VIEW_TEMPLATE = 'view_template',
  VIEW_TOOL = 'view_tool',
  VIEW_SOURCE = 'view_source',
  VIEW_TALK = 'view_talk',
  VIEW_CUSTOMER_SERVICE = 'view_customer_service',
  VIEW_USER = 'view_user',
  ADMIN_ALL = 'admin_all'
}

// 用户信息接口
export interface UserInfo {
  id: string;
  openid: string;
  nickname: string;
  headimgurl: string;
  role: UserRole;
  permissions: Permission[];
  unionid?: string;
  accessToken?: string;
}

// 登录状态接口
export interface AuthState {
  isAuthenticated: boolean;
  user: UserInfo | null;
  loading: boolean;
  error: string | null;
}

// 角色权限映射
export const ROLE_PERMISSIONS: Record<UserRole, Permission[]> = {
  [UserRole.ADMIN]: [
    Permission.VIEW_HOME,
    Permission.VIEW_CREATE,
    Permission.VIEW_AI,
    Permission.VIEW_TEMPLATE,
    Permission.VIEW_TOOL,
    Permission.VIEW_SOURCE,
    Permission.VIEW_TALK,
    Permission.VIEW_CUSTOMER_SERVICE,
    Permission.VIEW_USER,
    Permission.ADMIN_ALL
  ],
  [UserRole.USER]: [
    Permission.VIEW_HOME,
    Permission.VIEW_CREATE
  ]
}; 